refactor chain to app