added locking functionality