Refactor DB helpers