Rewrite Data and add tests