adding validation to add query method