Clean up image code in controller.js