Moved saving JS to separate file