Maybe clearer to replace the resolve fun with a lists:foldl.