move inference into new module