tidied up variable storage and added confirming states for locks