First working version of assignment 9