some calls to c code, should be modified using state_m