first completed working version of assignment 2