replace pseudo code for recursive check fitness