Added Schema class and code refactored