fixed a bug with memory checking.