change to use generator. Yes, luckily it worked for array/list, but I changed it to use tuple as suggested.