Condensed if statements and removed unnecessary code