reorder some blocks of code to follow the storyline