optimzed the portfolio storage and improved debug printing