removing some code duplication