<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def draw(self, surface, rect, surfaces=None):
 """ Draw the map onto a surface pass a rect that defines the draw area for: drawing to an area smaller that the whole window/screen surfaces may optionally be passed that will be blitted onto the surface. this must be a sequence of tuples containing a layer number, image, and rect in screen coordinates. surfaces will be drawn in order passed, and will be correctly drawn with tiles from a higher layer overlapping the surface. surfaces list should be in the following format: or this: :param surface: pygame surface to draw to :param rect: area to draw to :param surfaces: optional sequence of surfaces to interlace between tiles :return rect: area that was drawn over """

        if self._zoom_level == 1.0:
            self._render_map(surface, rect, surfaces)
        else:
            self._render_map(self._zoom_buffer, self._zoom_buffer.get_rect(), surfaces)
            self.scaling_function(self._zoom_buffer, rect.size, surface)
        return self._previous_blit.copy()