Refactor avarage pages