Moved counterLock definition to the beginning