added generic function. logic server-side. client-side drawing.