fixed erase method bug that could have caused buffer overflow