use mapAccumL for fun