gras: moved the lock/unlock here