Simply restructed and added a bit more commenting