Move argument parsing into separate function