added the logic for accordion