added null checking