use null instead of undefined to detect if a layer is present or not. This avoids the evil undefined