Fixed error with passing by reference