updated with Lupo's code and output files