iterative solution to P0304