basically working set_ir stuff (untested!)