moving helper function definitions