Working on output

and simplified code