Refactoring getNTimes