refactor courses_controller