Modified and extended programatic output, converted all print statement to stdout or stderr