extracted method to remove duplication