use with_lock to prevent DEADLOCKS