changed exception to ref