refactoring according to comments