Reorganize code blocks