Moving JS to drawing.js