refactored routes and messages controller