extract method to avoid dupplicated code