This is JavaScript, not Python :) Why not just move this to line 70, then you wouldn't need to check for fail or stack.