added checks for empty sources