Worked on a bit of the error checking