Close DB method, refactoring