modify for stack overflow errors in 10.8 and 10.9