fixed for loops, changed layout of partitioning