ajax_demo: increased code efficiency