completed the implementation and added answers to exercies