cleaned up parseQueryArgs function