adding some null checks