use url lib instead of custom parsing