some refactoring (code review)