some refactoring
merged changes