added checks for empty