Implemented the rest of the contract functionality