Refactoring CSS formatting code