cleaned up munging quite a bit