minor change to avoid traversing whole list with fold