refactor db in separate class