Added a chain of responsibility pattern.