Code refined (line aligned, method renamed, logic changed lightly