refactor code into controllers/services files