add some comments and improve message output