refactoring the response writer.