fix bug in SMA