changed controller.js from just variables to functions