Fixed drawRectangle function