base function for svm