minor change to improve numerical stability