some comments and error checking