moving db logic to separated module