formatting & comments
refine logic to exit earlier when able