Move code in a dedicate function