Add wrapper around the inserting command to manage deadlock/lock