added exception for nans in final solution