Fix bug with duplicate entries