Rewrote the complex version of the /lock command