switch all of algorithm