sample size refactoring