implemented main part of irl, need test