use factory pattern to create db instance