rewrite if statement with cleaner style