Made some changes.

Implemented the cases 1, 2, 3. They do not work correctly yet!