Change (a == NULL) condition to (!a) and (a != NULL) condition to (a).