factor out unnecessary function