implemented most of lab 2