walker function refactored