Adding in error messages and correct output.