fix bugs with result saving related to NULL values and empty strings

my god, why has it to be so complicated