second version(with validation)