fix b-splines algorithm