Port to logging instead of using print commands