fixed wrong memory access