JS Extraction & Duplicate

Extracted JS to own file, duplicated it to split-edit.