Added comments to make everything clearer