Added some comments to make this clearer