more understandable implementation of the flat stack
ignore pycache