solved without repetitions