Added ternary operator. trans_by_grids works for the first time, but needs a test.