use one method to remove some code duplications