added saving pages state to database