created the beginning from sample code from ex1