add LWTA code (last index tie breaking)