improving double slash logic for _build_rest method