Added clear layer logic