reduce some code duplication