Refactored getOutput to calcOutput
Added gate param to calcOutput