cleanup
refactored to use one stack
Renaming variables