Added check for duplicate item in an array