fix while loop exit for Opal compatibility