replace case statement with if/else