added some explanation and a little code change for a logic