Refactored code to prep for data querying functionalities