replace modCount with modStack to support diamond-shaped setups