fixes #2366 Checks for type before casting to avoid exception.
Remove line of nonsense code.