If you post a code snippet, ALWAYS USE CODE TAGS:
How to use code tags: Using code tags properly
You will need some form of state machine to transition between zero, 1 or 2 fingers in contact.
It may be helpful to you to diagram out the various states this UI can exist in and then begin your coding adventure working from that directed graph of states and transition conditions.