fixed handling of null and empty input