fixed the loop that was hardcoded using phps array_slice method