Rework algorithm to run on validpapers only