add more defensive coding