some logic update, and comments