Fixed null-checking for variables