simplify dump methodi, use new instead of malloc