had trouble with pointer and reference