Fix wrong grouping of modulo exporessions

Algorithm works now
Just have to close shape from last to first index