Finished converting functionality to JS.