updated code based on
http://codereview.stackexchange.com/questions/55499/munging-data-off-wals