initial solution to rprog assignment 2