refactored our code  to use the Database class