make the code more robust