Adding timeout function to all controllers.