validation and save