solved hw 4 both ways