improved databasehandler