refactored datasource factory