more robust data validation