Modified so that it now works for nested slides.