remove spaces from URL routing

Refactor and prettify existing functions