variable 'year' referenced before assignment