added more comments to explain process