added dependency input, and wrote a nice generalised output commend