Added an error checking function and some notes