refactory gate directory