added counter to get rid of repeats