fixed repainting
added some extra traversing logic to make render life easier