guard against stack out of bounds