main now handles input errors