Added null checking