Fixed if logic