validate and santize input/output