revise scala map to fold