Calculating depth on each page (in progress)