Refactor code
Fix isue with invalid url creation