collect repeated numbers to set and using Objects.equals() to prevent NPE