Change <= to < and make variable instead of using same function 3 times