extracted javascript
formatting