preparing separtion by index function to be used in parallel