Finally the drawing function seems to be working OK