update, convert code to C