cleaning up some if statement logic