Extract some common functionality and remove one function only used once