made some refactoring