rewrite of shortcutting algorithm to accomodate granularity parameter