Why not have each of these as a separate `if` instead of one long `if`, `elseif`, `else` and then check the return status of the previous method. That way if one method fails the next one will be tried.