update the between function