checked with CSIS lab Matlab, made some corrections