working add_sma refactored