fixed incorrect memory access