Refactored to separate db work.