main function is now handling flag dispatch