factorize some code