Added db factory singleton pattern