moved url parsing into its own function