wal: refactor