Added layer toggle logic.