Improoved snake-drawing algorithm