a bit of refactoring: extracted two methods