little rewrite of euclid