print perfected to handle exceptions