modified kevin's SVM functions