fix memory access error