nested loops for portfolio