Refactor adjacent calculation and walk method