Concurrency - MongoDB Find and Insert on 2 Different Collections

I am having a problem dealing with concurrency in my web application.

I have a locking system that works with 2 MongoDB collections, an item collection and a lock collection.The locking system prevents multiple users from processing the same "item" by creating a lock document in the db. Whenever a user wants to process an item, it will first check if the item exists and if there is a lock document created for this item, if there isn't it will create a lock document for it. The lock will be released when the user is finished with processing the item.

The problem occurs when 2 users click on the same item at the same time, this will allow both users to process the same document since the code is checking for a lock document concurrently.

I have searched around and there doesn't seem to be an answer that fits my situation, so I'm hoping someone can help me out.

Is there a way in to prevent this from happen or does the system need to be designed another way to fix this?

Thanks in advance.