got it working! small problem from way index loops though