Changed function for locking