corrected as per hw 4