fix stack clearing