find pattern then store it for latter use