fixed some bugs with page management