refactor inferStatement into pieces