reorg some functions
updated origin pattern rules