finalizing the implemantation that pass all tests