Refactored to use Script design pattern