improve if statement in main