Add comments and error management