refactored to reduce a completely unnecessary conversion and check for type.