Imporved bezier curve algorithm