abstracted branches function