refatctor for testing