Factorize some code lines