Add error check.
Reformating output and source code.