broke out external function and added test