after some refactoring