added comments to make it make sense