serialize data before frontend passing