refactored the routes (removed duplicated code)