Add one check for leftArray and add some comments to code