refactoring our code to use the database class