moved db functions to Database.pm