Added input flags and basic error handling