Refactor the functions from the __main__ calls. Now this functions can be used from other script.