I mean the code below (20 lines) should be in a separate function.