fix check for empty input case