made more robust