Adding Check for null data and selection