fixed invalid memory operations