refactoring to return an HttpResponse object