Adding serialize function, optimized size with empty