db: refactored