urgent fix for nan issue when computing the optimal point