fixing regex for urls; refactoring