refactoring and extracting methods