Refactor the data access code into a separate package