fixed exception when records is empty.