Refactoring: extracted some methods.