Updated to use the to_json functionality.