Updated code to improve outputs to console window