Avoid unnecessary object duplication using passing arguments by reference