refactored glow code