Rearranging and commenting code a little
Refactoring