Implemented the code