Cross checked c4 code, in theory it is all OK, whether it fits with Sands method requires more thought