clusterng implemented. input of optimize was improved