Added some sanity checking to output