moved assignment out of EOF block