New function: getFirstValid()