You move your optimize() calls to outside of the while asset loop. Now instead of six optimized variables, you get two optimized variables, which will then be common to all assets.