FIx error on loop