fixed subtle memory reading error (if bug)