Refactored hook_menu to minimize function calls