Wrap the code in a function + cleaning