Fixed URLEncode so it is shorter and more efficient, updated code to reflect change in the function