Assignment 2 rewrite