move adapt prob code to dedicated file