more refactoring and helpers