complitly rewrite (not full progress)