fixed some null checks