implemented multilevel locking with intent (in a weird but easy way)