Re-built the draw function without jQuery