Moved logic to url model and some refactoring