Fixing javascript/controller functions