Cost Function calculation correct now. wooof