moved canvas js code