fix numerical issues