tidied and review controller.js