Added check for empty cond in order to avoid function calls with empty input which may lead to failure.