refactored js for accordion