protected function returnResult($data, $status = "ok")
    {
        $referrer = $this->sessionBag->get("referrer");
        if (!empty($referrer)) {
            return $this->redirect($referrer);
        } else {
            return new Response(jsonDecode(array_replace(array("status" => $status), (array) $data)), 200, $this->defaultResponseHeaders);
        }
    }