improved handling of infinity