serialize data before storing in backend