Replaced flatnum with foldLeft