First working version of assignment 2