fixed bug when adding new page when writing to end of memory