restructure main with interrupt comments