Refactor: extract throw_if function