some refactoring)