Implemented the two functions