refactor url encoding