use mutable references instead of copies everywhere.