Fix undefined value when there is no recored in database