corrected issue with the infinite looping issue