rewrites integrated almost completely