add loop and idx
rework indexing & loops