modified to follow up on stack