logic extracted in a function