Solved the problem with gates.