This code was written to match what R does- is there a reason why you're changing this?