added the second functionality of part A