finished rprog assignment 2