fix flushPages bug