Implemented optimistic locking