Implemented all the functions, I think