Fix var method when data is undefined