fix mode 0 and implement mode 2