pointer reference bug fixed