added friendly message for casting errors.