order the code to read like the problem