Implemented the logic.