how to get from x to y pattern