rough completion of proj1 (need code cleaning and comments)