implemented addRectangle method