will move to a top-level function