added extra null check and Any() check