cleaned up more output. Added error checking