implement gate test function