handle infinite values more gracefully