Adding checks for null and empty input cases