Final Code for Stack Check