code from first half of class