making switch branch work with ajax