Added null checking.