added output function to replace print statements in debug flag check.