Does this need to be a proc?  It seems like 0..MAX_PAGES can be defined right away.