added a check routine for distinct elements