Modifying controller.js to match the changes in the old library