Algo rewrite