Removing redundant if statements now variable based