moving pages logic to separate file