Re-factored JS.
Re-factored JS.