added model attributes checking (using reflection), some refactoring