rewrite of algebrasp