Adding first half of lab6.