duplicate contacts gets created due wrong end of foreach loop.