walk function refined