refactoring recordRoll function