refactor accounts controller