partial implementation but in sync with c42 and compilable