a more robust version.