refactoring for better reasoning