Refactor, move the code inside a method