Fix a duplicate code in controller