Extract code into separate functions
Some name refactoring