some refactoring,
adds possibility to specifiy schema