Refactored to modularise controller.js into separate script files