modified thread_controller.php