Refs #3946: improve logic and comment to make the code mnd logs ore understandable