improved code for urls generation