Fixed invalid memory access