add basic logic and some comments