refactor and add two patterns