Added checkResult() to prevent needless recursive calls just to check if the result is valid.