added code and comments to complete app