implemented controlled-not gate