how to write a pattern