moved debug print statements to logging.