Refactored Javascript to remove slowdown
Pulling request