changed pass by pointer to by reference