more refactoring + example