extract out functions