added checks for null results