Improve If statement and binary operations