protected against -nan numbers