More robust code for raw output