redesigned rendering a bit so it  is more oo