Refactor all calls within an if, which is illegal