updated code to output log file fr PYP