Generalizing the ui locking mech