Refactoring and fixing chaining issue