Refactor code for reusability
simplify css colouring