update C version, almost finish