using reduce instead of forEach when creating the JsonObject
using collect instead of reduce when creating the JsonObject