improve command substitution, but still bugy