adding some comments and error handling to class setup