add some null checks