type safety for serializable functions