refactoring to understand the accordion functinality