fix ugly if statement