added null check for the results