updated methods to take references rather than pass by value