refactore dispatcher.php