code of the first assignment improved