Fix "undefined" issue on first visit