Refactor of AccountsController.js