Move some code in dedicated functions