restructured code blocks, no funcitonal changes