Extracted the querying for data from the UI into its own object.