added output handling