fixed bugs with new records/deleting last record