Implemented Code for part A