fixed backwards null check