Changed the findPeriodic function