detect output and input formats dinamically.