The logic consisting of goto and continue is confusing. Use a loop?