fixed index error when classes do not start at zero