Implemented the second task.