create schema method + some refactoring