Adding code from unit 2 & 3