refined the formula of gesture mode