fixed while-statements and globals