coloring and some refactoring