updated the encode call to use the active formatter's encoding method