Fixed pointer reference bug