implemented much faster version with canvas.