add in some null checking