Worked around InvalidCastException