Converted 2.3 to main, validate input