changed implement stacked register from recursive to iterative.