refactored the code to use the database class