main updated with validation