fixed improper memory access