corrected error in exitFor() function