Move logic to a couple of functions and parse args only in __main__