Refactor the DB Handler