conslidate, these functions were almost identical