improved hand holding algorithm