refactoring multiple database support