checking type in a saner way. fixes issue 5567