refactor with() method