add some comments and some error handeling