Refactoring, added url generation algorithm