fixed flickering on re-render (due to having color classes state be initialized empty) and made code cleaner