Implemented all the functions