moved var declaration to where it can be useful