Added some logic of empty records