modified shingles algorithm