refactoring methods and moving some of them to file_handler.