Implemented proper painting of images for grouping, if the objects are contained within another object