added a mode to flip the stack order, maybe its easier to understand...