Added logic for not returning duplicate words