how to calculate gate offset - Search