Fix; while loop type was wrong for delegate

Not sure if this is the greatest solution; but works.