a few tweaks from henry and vignesh