Minor refactor

Changed a variable name and put a overflow  check into a more logical place