Added some comments and validation