casting a function to serialize