added code to handle duplicate items in transaction