some refactoring after review