added locking mechanism for long running commands