fix js error making layer arrays global