Refactoring db call