1. added comments to the controllers.
2. moved some of the repeated functions in the controllers into a service.