added check of lock status immediately before sending lock/unlock command