Make the PHP code more robust