updated to work with multiple canvases