refactoring the URL param handling logic