Added some comments and error popup