Refactored javascript
Adjusted needle