fixed issues related to exercise 7 and implemented using prototype