refactor to use more idiomatic pipes for cmd