Replaced if/else by case statment