added comments and validation