Factorize
Fix spaces and alignment
Merge pull request #150 from lucasmichot/chains-functions

Factorize some functions