more error checking

Change-Id: I56694dfd344ff0cb869c52fd0b215da6d6d35517