handles duplicates correctly now. should be working completely
more test cases