reordered gdoc program to be more readible