Refactored effect code.