Fixed NaN bug in constraint