added isLocked check