switched some pointers to references