Simple refactoring to organize functions and naming better