Preventing infinite loops in the getCycle method
Fixed the TLE. now WA...