Add some comments and move some code into a functions