added null check for result