Added output handling