Added optimization part.