Better error handling for the mod function.