completed implementing all function. need to debug