Added error checking and comments, ready to turn in.