make dump() return a string instead of printing it