further refactoring of database functions