added adaptive sub implementation. Doesnt work perfect, should debug