extract method on some shared logic