adde full comments and cleaned up the code
forgot to remove a couple of lines