made index script recursive