refactored javascript
fix merge error with alex pull request