moved file level variables up to closure scope