Fixed null checking