refactored to new database interface