fixing index errors