Make code more defensive