Refactor args parsing