refactored DBManager to remove duplicate code