var should be defined at top