move moduledecl into consuming function