fixed issue with the drawing function