optimize det_mod_pk_SE_row_23() and its subroutines