made fixes to memory access calculation