Fix error in null checking