simpler attempt at using for loops to find unique elements instead of Set