Cleaned up example with more idiomatic Rust