Improved bezier curves calculation