Move checking code to function, used for component coloring in menu