Moved command line argument handeling to functions