more idiomatic go refactor