Refactoring, extracted a few methods