refactored logic to generate query url and stuff json into models into helper