fourth chapter's implementation