simplifying the code for printing error and progress messages