Implemented loop based on hidden candidates

Now all candidates are found to be wrapped. The only thing that is affected here is the performance from avg of 5ms to an avg of 30ms, about 6 times slower.