(menu_common_backend.c) Refactor duplicate code