Replaced deprecated URLEncoder.encode() with new convenience method