A new algorithm for the solution of the secondary optimization problem in non-serial dynamic programming