t516: add checking to avoid null pointer exception