changed munge function