refactor code into the router for getting params