added function scope to all js