Error: Too many output arguments

Exactly. The code needs to be sequentially executable without relying on objects whose value has not yet been computed. Otherwise, you are back to a problem of solving simultaneous equations.