NODEJS - Functionalize the travesal