Replace $db with $this->db