updated version supplied by course instrcutor