I'd move this to the very start of the function, since it does input-validation