modular code - works with 2 input and 1 input gates