getting the code into reasonable shape