Fixes if statement logic