rearranging lines
added clarification in comments