refactored reaction function pattern, and constant class refactored