refactoring sample2 and 3