Refactored teacherscontroller.rb