added size tracking to erase method