Refactored theme code