refactoring the code and the color feature has been added